package cn.stylefeng.guns.modular.weixin.controller;

import com.github.binarywang.wxpay.service.*;
import org.springframework.beans.factory.annotation.*;
import com.github.binarywang.wxpay.exception.*;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;
import com.github.binarywang.wxpay.bean.entpay.*;

@Api("\u4f01\u4e1a\u4ed8\u6b3e")
@RequestMapping({ "/pay" })
@RestController
public class EntPayController
{
    private WxPayService wxService;
    
    @Autowired
    public EntPayController(final WxPayService wxService) {
        this.wxService = wxService;
    }
    
    @ApiOperation("\u4f01\u4e1a\u4ed8\u6b3e\u5230\u96f6\u94b1")
    @PostMapping({ "/entPay" })
    public EntPayResult entPay(@RequestBody final EntPayRequest request) throws WxPayException {
        return this.wxService.getEntPayService().entPay(request);
    }
    
    @ApiOperation("\u67e5\u8be2\u4f01\u4e1a\u4ed8\u6b3e\u5230\u96f6\u94b1\u7684\u7ed3\u679c")
    @GetMapping({ "/queryEntPay/{partnerTradeNo}" })
    public EntPayQueryResult queryEntPay(@PathVariable final String partnerTradeNo) throws WxPayException {
        return this.wxService.getEntPayService().queryEntPay(partnerTradeNo);
    }
    
    @ApiOperation("\u83b7\u53d6RSA\u52a0\u5bc6\u516c\u94a5")
    @GetMapping({ "/getPublicKey" })
    public String getPublicKey() throws WxPayException {
        return this.wxService.getEntPayService().getPublicKey();
    }
    
    @ApiOperation("\u4f01\u4e1a\u4ed8\u6b3e\u5230\u94f6\u884c\u5361")
    @PostMapping({ "/payBank" })
    public EntPayBankResult payBank(final EntPayBankRequest request) throws WxPayException {
        return this.wxService.getEntPayService().payBank(request);
    }
    
    @ApiOperation("\u67e5\u8be2\u4f01\u4e1a\u4ed8\u6b3e\u5230\u94f6\u884c\u5361\u7684\u7ed3\u679c")
    @GetMapping({ "/queryPayBank/{partnerTradeNo}" })
    public EntPayBankQueryResult queryPayBank(@PathVariable final String partnerTradeNo) throws WxPayException {
        return this.wxService.getEntPayService().queryPayBank(partnerTradeNo);
    }
}
